package jnpf.service.impl;

import jnpf.entity.Whut_camera_manageEntity;
import jnpf.mapper.Whut_camera_manageMapper;
import jnpf.service.Whut_camera_manageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.util.RandomUtil;


import jnpf.model.whut_camera_manage.Whut_camera_managePagination;
import java.util.stream.Collectors;





import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.text.SimpleDateFormat;
import jnpf.util.*;
import java.util.*;

/**
 *
 * whut_camera_manage
 * 版本： V3.2.0
 * 版权： 引迈信息技术有限公司（https://www.jnpfsoft.com）
 * 作者： JNPF开发平台组
 * 日期： 2024-10-01
 */
@Service

public class Whut_camera_manageServiceImpl extends ServiceImpl<Whut_camera_manageMapper, Whut_camera_manageEntity> implements Whut_camera_manageService {

    @Autowired
    private UserProvider userProvider;

    @Override
    public List<Whut_camera_manageEntity> getList(Whut_camera_managePagination whut_camera_managePagination){
        String userId=userProvider.get().getUserId();
        List<String> AllIdList =new ArrayList();
        int total=0;
                    QueryWrapper<Whut_camera_manageEntity> whut_camera_manageQueryWrapper=new QueryWrapper<>();
            int whut_camera_manageNum =0;
			if(StringUtil.isNotEmpty(whut_camera_managePagination.getCode())){
            whut_camera_manageNum++;
            whut_camera_manageQueryWrapper.lambda().eq(Whut_camera_manageEntity::getCode,whut_camera_managePagination.getCode());
                    }

			if(StringUtil.isNotEmpty(whut_camera_managePagination.getNumber())){
            whut_camera_manageNum++;
            whut_camera_manageQueryWrapper.lambda().eq(Whut_camera_manageEntity::getNumber,whut_camera_managePagination.getNumber());
                    }

			if(StringUtil.isNotEmpty(whut_camera_managePagination.getSite())){
            whut_camera_manageNum++;
            whut_camera_manageQueryWrapper.lambda().like(Whut_camera_manageEntity::getSite,whut_camera_managePagination.getSite());
                    }

        if(AllIdList.size()>0){
            whut_camera_manageQueryWrapper.lambda().in(Whut_camera_manageEntity::getId, AllIdList);
        }
        //排序
        if(StringUtil.isEmpty(whut_camera_managePagination.getSidx())){
        whut_camera_manageQueryWrapper.lambda().orderByDesc(Whut_camera_manageEntity::getId);
        }else{
        whut_camera_manageQueryWrapper="asc".equals(whut_camera_managePagination.getSort().toLowerCase())?whut_camera_manageQueryWrapper.orderByAsc(whut_camera_managePagination.getSidx()):whut_camera_manageQueryWrapper.orderByDesc(whut_camera_managePagination.getSidx());
        }
        if((total>0 && AllIdList.size()>0) || total==0){
        Page<Whut_camera_manageEntity> page=new Page<>(whut_camera_managePagination.getCurrentPage(), whut_camera_managePagination.getPageSize());
        IPage<Whut_camera_manageEntity> userIPage=this.page(page, whut_camera_manageQueryWrapper);
        return whut_camera_managePagination.setData(userIPage.getRecords(),userIPage.getTotal());
        }else{
            List<Whut_camera_manageEntity> list = new ArrayList();
            return whut_camera_managePagination.setData(list, list.size());
        }
    }
    @Override
    public List<Whut_camera_manageEntity> getTypeList(Whut_camera_managePagination whut_camera_managePagination,String dataType){
        String userId=userProvider.get().getUserId();
        List<String> AllIdList =new ArrayList();
		int total=0;
                    QueryWrapper<Whut_camera_manageEntity> whut_camera_manageQueryWrapper=new QueryWrapper<>();
            int whut_camera_manageNum =0;
			if(StringUtil.isNotEmpty(whut_camera_managePagination.getCode())){
            whut_camera_manageNum++;
            whut_camera_manageQueryWrapper.lambda().like(Whut_camera_manageEntity::getCode,whut_camera_managePagination.getCode());
                    }

			if(StringUtil.isNotEmpty(whut_camera_managePagination.getNumber())){
            whut_camera_manageNum++;
            whut_camera_manageQueryWrapper.lambda().like(Whut_camera_manageEntity::getNumber,whut_camera_managePagination.getNumber());
                    }

			if(StringUtil.isNotEmpty(whut_camera_managePagination.getSite())){
            whut_camera_manageNum++;
            whut_camera_manageQueryWrapper.lambda().like(Whut_camera_manageEntity::getSite,whut_camera_managePagination.getSite());
                    }

		if(AllIdList.size()>0){
        whut_camera_manageQueryWrapper.lambda().in(Whut_camera_manageEntity::getId, AllIdList);
				}
        //排序
        if(StringUtil.isEmpty(whut_camera_managePagination.getSidx())){
        whut_camera_manageQueryWrapper.lambda().orderByDesc(Whut_camera_manageEntity::getId);
        }else{
        whut_camera_manageQueryWrapper="asc".equals(whut_camera_managePagination.getSort().toLowerCase())?whut_camera_manageQueryWrapper.orderByAsc(whut_camera_managePagination.getSidx()):whut_camera_manageQueryWrapper.orderByDesc(whut_camera_managePagination.getSidx());
        }
        if("0".equals(dataType)){
            if((total>0 && AllIdList.size()>0) || total==0){
                Page<Whut_camera_manageEntity> page=new Page<>(whut_camera_managePagination.getCurrentPage(), whut_camera_managePagination.getPageSize());
                IPage<Whut_camera_manageEntity> userIPage=this.page(page, whut_camera_manageQueryWrapper);
                return whut_camera_managePagination.setData(userIPage.getRecords(),userIPage.getTotal());
            }else{
                List<Whut_camera_manageEntity> list = new ArrayList();
                return whut_camera_managePagination.setData(list, list.size());
            }
        }else{
            return this.list(whut_camera_manageQueryWrapper);
        }
    }

    @Override
    public Whut_camera_manageEntity getInfo(String id){
        QueryWrapper<Whut_camera_manageEntity> queryWrapper=new QueryWrapper<>();
        queryWrapper.lambda().eq(Whut_camera_manageEntity::getId,id);
        return this.getOne(queryWrapper);
    }

    @Override
    public void create(Whut_camera_manageEntity entity){
        this.save(entity);
    }

    @Override
    public boolean update(String id, Whut_camera_manageEntity entity){
        entity.setId(id);
        return this.updateById(entity);
    }
    @Override
    public void delete(Whut_camera_manageEntity entity){
        if(entity!=null){
            this.removeById(entity.getId());
        }
    }
    //子表方法

    //列表子表数据方法

}